#ifndef VEHICLE_H
#define VEHICLE_H
#include "opencv2/opencv.hpp"

#include <QObject>
#include <QDebug>
using namespace cv;


class Vehicle
{
public:
    Vehicle();
    void realxyhInit(double mx,double my,double Degheading);
    void InitSensor();
    void update1(double nAng,double nspeed,double interval);
    void update(double nTarspdl,double nTarspdr,double interval);

    double x(){return realx/sceneScale;}
    double y(){return realy/sceneScale;}
    double headang(){return realheading;}
    double sensorx(){return senx;}
    double sensory(){return seny;}
    double sensorheading(){return senheading;}

    void setpath(QVector<QPointF>* npath )
    {
        path=npath;
        qDebug()<<path;
    }
    double realx;
    double realy;
    double realheading;
private:
    void sen(double nspdl, double nspdr,double interval);
    void Rotate2(double x1, double y1, double alpha, double& x2, double& y2);
    double r;               //转向半径
    double spd;             //m/s
    double spdl;            //m/s   正为向前，负为向后   俯视车辆，车头向前，左侧车轮为左
    double spdr;            //m/s   正为向前，负为向后
    double wheelbase=0.24;  //轮距
    double wheeldim=0.08;   //轮径


    double senx;
    double seny;
    double senheading;

    double vehr=0.15;        //车辆半径，用于碰撞检测
    double sceneScale=0.01;  //地图的比例：1像素对应0.01m

    Mat Realworld;
    bool realxyhInited=false;
    double crtSpdL=0;
    double crtSpdR=0;
    double Accl=100;  //rps

    QVector<QPointF>* path;
};

#endif // VEHICLE_H
